package com.qf.ex_handler;

import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerExceptionResolver;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

//这种异常处理器实现方式，对于处理器参数封装出现的异常，不会交给这个异常处理器处理的
//@Component
public class MyExceptionHandler1 implements HandlerExceptionResolver {
    @Override
    public ModelAndView resolveException(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) {
        System.out.println("11111");

        //收集错误信息，告诉开发人员（一般在公司是以邮件形式，通知开发人员）


        ModelAndView mav = new ModelAndView();
        mav.setViewName("/error.jsp");

        return mav;
    }
}
